<div class="container-fluid">
    <div class="row">
      <div class="col-lg-12">
        <div class="card">
        	<ul class="nav nav-tabs mb-3" id="myTab" role="tablist">
		        <li class="nav-item" role="presentation">
		          <button class="nav-link active" id="base-tab" data-bs-toggle="tab" data-bs-target="#base" type="button" role="tab" aria-controls="base" aria-selected="false">基础设置</button>
		        </li>
		        <li class="nav-item" role="presentation">
		          <button class="nav-link" id="wx-tab" data-bs-toggle="tab" data-bs-target="#wx" type="button" role="tab" aria-controls="wx" aria-selected="false">微信参数</button>
		        </li>
		        <li class="nav-item" role="presentation">
		          <button class="nav-link" id="ali-tab" data-bs-toggle="tab" data-bs-target="#ali" type="button" role="tab" aria-controls="ali" aria-selected="false">支付宝参数</button>
		        </li>
		      </ul>
		      <div class="card-body">
	            <form action="" method="post">
			      <div class="tab-content" id="myTabContent">
				  	<div class="tab-pane fade show active" id="base" role="tabpanel" aria-labelledby="base-tab">
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">系统名称</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control" name="base[title]" value="{{$settings['base']['title'] ?? ''}}" placeholder="请填写系统名称">
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">系统说明</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control" name="base[desc]" value="{{$settings['base']['desc'] ?? ''}}" placeholder="请填写系统说明">
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">最低提现金额</label>
					    <div class="col-sm-10">
					      <input type="number" min='0' class="form-control" name="base[minwith]" value="{{$settings['base']['minwith'] ?? ''}}" placeholder="请填写最低提现金额">
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">系统底部版权</label>
					    <div class="col-sm-10">
					      <input type="text" class="form-control" name="base[copyright]" value="{{$settings['base']['copyright'] ?? ''}}" placeholder="请填写系统底部版权">
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">话费充值说明</label>
					    <div class="col-sm-10">
					      <textarea class="form-control" style="min-height: 250px" name="base[feerule]">{{$settings['base']['feerule'] ?? ''}}</textarea>
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">电费充值说明</label>
					    <div class="col-sm-10">
					      <textarea class="form-control" style="min-height: 250px" name="base[feerule2]">{{$settings['base']['feerule2'] ?? ''}}</textarea>
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">燃气充值说明</label>
					    <div class="col-sm-10">
					      <textarea class="form-control" style="min-height: 250px" name="base[feerule3]">{{$settings['base']['feerule3'] ?? ''}}</textarea>
					    </div>
					  </div>
					  <div class="mb-3 row">
					    <label class="col-sm-1 col-form-label">提现说明</label>
					    <div class="col-sm-10">
					      <textarea class="form-control" style="min-height: 250px" name="base[withrule]">{{$settings['base']['withrule'] ?? ''}}</textarea>
					    </div>
					  </div>
			        </div>

				    <div class="tab-pane fade" id="wx" role="tabpanel" aria-labelledby="wx-tab">
						<div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">公众号appid</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="wxpay[appid]" placeholder="请填写公众号appid" value="{{empty($settings['wxpay']['appid'])?'':$settings['wxpay']['appid']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">公众号appsecret</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="wxpay[appsecret]" placeholder="请填写公众号appsecret" value="{{empty($settings['wxpay']['appsecret'])?'':$settings['wxpay']['appsecret']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">商户号</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="wxpay[mchid]" placeholder="请填写商户号" value="{{empty($settings['wxpay']['mchid'])?'':$settings['wxpay']['mchid']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">APIv3秘钥</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="wxpay[apikey]" placeholder="请填写支付秘钥" value="{{empty($settings['wxpay']['apikey'])?'':$settings['wxpay']['apikey']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">证书序列号</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="wxpay[serialno]" placeholder="请填写证书序列号" value="{{empty($settings['wxpay']['serialno'])?'':$settings['wxpay']['serialno']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">支付证书私钥</label>
                            <div class="col-sm-10">
                                <textarea rows="5" class="form-control" name="wxpay[pvkey]" >{{empty($settings['wxpay']['pvkey'])?'':$settings['wxpay']['pvkey']}}</textarea>
                            </div>
                        </div>
					</div>

				    <div class="tab-pane fade" id="ali" role="tabpanel" aria-labelledby="ali-tab">
						<div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">支付宝Appid</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="alipay[appid]" placeholder="请填写支付宝Appid" value="{{empty($settings['alipay']['appid'])?'':$settings['alipay']['appid']}}">
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">支付宝公钥</label>
                            <div class="col-sm-10">
                                <textarea rows="5" class="form-control" name="alipay[pbkey]" placeholder="{{empty($settings['alipay']['pbkeydone'])?'请填写支付宝公钥':'已保存 不填则不修改'}}"></textarea>
                            </div>
                        </div>
                        <div class="mb-3 row">
                            <label class="col-sm-1 col-form-label">支付宝应用私钥</label>
                            <div class="col-sm-10">
                                <textarea rows="5" class="form-control" name="alipay[pvkey]" placeholder="{{empty($settings['alipay']['pvkeydone'])?'请填写支付宝应用私钥':'已保存 不填则不修改'}}"></textarea>
                            </div>
                        </div>
					</div>
			      </div>
		      	<div onclick='onSubmit(this)' class="btn btn-primary">保存</div>
			    </form>
          </div>
        </div>
      </div>
    </div>
</div>
<script>
function onSubmit(btn){
	$(btn).attr('disable', 'true');
    var l = $(btn).lyearloading({
        opacity: 0.2,
        spinnerSize: 'nm'
    });
	$.ajax({
		url:"/SPAdmin/set/post",
		type:'post',
		data:$('form').serialize(),
		dataType:'json',
		success:function(res){
			$(btn).prop('disable', 'false');
	        l.destroy();
	        
			if(res.code == 1){
				$.notify('保存成功');
				setTimeout(function(){
					location.href = '/SPAdmin/set';
				},1500);
			}else $.notify(res.msg);
		}
	});
}
</script>